﻿using UnityEngine;
using System.Collections;
using DICE_GS;

public class UseItemIcon : uiBaseButton {
	
	public UILabel remainCountLabel;
	public ItemType itemType;
	public int itemIndex;
	public int itemCount;
	// Use this for initialization
	void Start () {

	}
	
	public void UpdateItemCount(int count)
	{
		itemCount = count;
//		remainCountLabel.text = itemCount.ToString();
	}
	
	void OnClick()
	{
		//if( MainHUDUI.Instance.itemBtn[itemIndex].isActive)
		//{
			Camera.main.gameObject.GetComponent<CameraControl>().PressedUIButton(true);
			UIManager.Instance.CallDelayedPressUp();
			
			PC_OP_USE_ITEM packet = new PC_OP_USE_ITEM();
			packet.ServerID = BoardManager.Instance.boardPerson_me.SID;

			packet.ItemType = (int)itemType;
	//		UpdateItemCount(itemCount-1);
			//CNetworkManager.Instance.SendPacket(packet.Protocol, packet.GetParam());
			CNetworkManager.Instance.SendPacket(packet);
			
			glog.debug ("send use item packet sid="+packet.ServerID+"  item="+packet.ItemType);
			//MainHUDUI.Instance.bUseHPItem = true;
			//UIManager.Instance.bUseSkill = true;
			//UIManager.Instance.ShowMoveRollButton(false);
		//	UIManager.Instance.CallDelayedPressUp();
			
		//	CheckDisable();
		//}
	}
	
//	void CheckDisable()
//	{
//		if(itemType == ItemType.HPPotion)
//		{
//			if(itemCount==0 || !MainHUDUI.Instance.myTeam.IsHPPotionUsable() )
//				MainHUDUI.Instance.DisableItemBtn1();
//		}
//		else if(itemType == ItemType.ResurrectPotion)
//		{
//			if(itemCount==0 || !MainHUDUI.Instance.myTeam.IsResurrectPotionUsable())
//				MainHUDUI.Instance.DisableItemBtn2();	
//		}			
//	}
}
